<?
// print_r($_POST);
//外网连内部接口
// $s= new SoapClient(null,array(
// "location" => "http://open.12301.cc/openService/pft_insideMX.php",
// "uri" => "www.16u.com?ac_16u=16ucom|pw_16u=c33367701511b4f6020ec61ded352059|auth_16u=true"));
include_once '/var/www/html/new/com.inc.php';
$ac=$GLOBALS['_ac'];
$pw=$GLOBALS['_pw'];
$s = new SoapClient(null,array("location" => "http://localhost/open/openService/pft_insideMX.php","uri" => "www.16u.com?ac_16u=$ac|pw_16u=$pw|auth_16u=true"));
$btime3 = $_GET['btime3']? $_GET['btime3'] : date('Y-m-d',strtotime('-3days'));
$lid = $_GET['lid'] ? $_GET['lid'] :'';

$n = 0;
// $aid = $_SESSION['memberID'];
// 查询已完成的订单数

for($date = $btime3;$date <= date('Y-m-d');$date = date('Y-m-d',strtotime($date)+86400)){
    $st = $date .' 00:00:00';
    $ed = $date .' 23:59:59';
    $x = $s -> Order_Globle_Search(
        "","", "$lid", "", "", "", "", "", "", "",
        "$st", "$ed", "", "", "", "", "", "", "1", "1",
        "0", "", "1", "0","","0","0", "0","","",
        "$aid", "", "", "", "");
    $ti1 .= $x.',';
    $temp_date = date('m-d',strtotime($date));
    $dates .= '"'.$temp_date.'",';
    $n++;
    if($n>30)break;//防止死循环
}
$ti1 = substr($ti1,0,-1);
//下单时的票数
for($date = $btime3;$date <= date('Y-m-d');$date = date('Y-m-d',strtotime($date)+86400)){
    $st = $date .' 00:00:00';
    $ed = $date .' 23:59:59';
    $x = $s -> Order_Globle_Search(
        "","", "$lid", "", "", "", "$st", "$ed", "", "",
        "", "", "", "", "", "", "", "", "1", "1",
        "0", "", "1", "0","","0","0", "0","","",
        "$aid", "", "", "", "");
    $ti2 .= $x.',';
    $temp_date = date('m-d',strtotime($date));
    $dates .= '"'.$temp_date.'",';
    $n++;
    if($n>30)break;//防止死循环
}

//$ti2 = $ti;
$ti2 = substr($ti2,0,-1);

//预计未来三天销量 根据订单有效期 状态未使用
for($i=1;$i<=3;$i++){

    $temp_date= date('m-d',strtotime('+'.$i.'days'));
    $dates .= '"'.$temp_date.'",';

    $btime2 = date('Y-m-d',strtotime('+'.$i.'days'));
    $x = $s -> Order_Globle_Search(
        "","", "$lid", "", "", "", "", "", "$btime2", "$btime2",
        "", "", "", "", "", "0", "", "", "1", "1",
        "0", "", "1", "0","","0","0", "0","","",
        "$aid", "", "", "", "");
    $ti3 .= $x.',';
}
$ti3 = substr($ti3,0,-1);
$dates = substr($dates,0,-1);
echo $ti1.'<br/>';
echo $ti2.'<br/>';
echo $ti3.'<br/>';?>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <title>ECharts</title>
    <script language="javascript" src="http://www.12301.cc/js/WdatePicker.js"></script>
    <script language="javascript" src="http://www.12301.cc/js/jquery-1.8.0.min.js"></script>
</head>
<body>
<form action="" method="post"  name="form" >
    <span class="lt">时间：</span>
    <input type="text" data-t="bt" id="txtStartTime" value="<?=$_REQUEST['bt']?>" name="bt" data-msg="请选择时间段" class="textInp w175 alliNameInp" autocomplete="off"/> 至
    <input type="text" data-t="et" id="txtEndTime" value="<?=$_REQUEST['et']?>" name="et" data-msg="请选择时间段" class="textInp w175 alliNameInp" autocomplete="off"/>

    <input type="submit" value="提交">
</form>
<!-- 为ECharts准备一个具备大小（宽高）的Dom -->
<div id="main" style="height:400px;width:800px"></div>
<!-- ECharts单文件引入 -->
<script src="//www.12301.cc/js/echarts-2.2.0/build/dist/echarts.js"></script>
<script type="text/javascript">
    // 路径配置
    require.config({
        paths: {
            echarts: '//www.12301.cc/js/echarts-2.2.0/build/dist'
        }
    });

    // 使用
    require(
        [
            'echarts',
            'echarts/chart/line' // 使用柱状图就加载bar模块
        ],
        function (ec) {
            // 基于准备好的dom，初始化echarts图表
            var myChart = ec.init(document.getElementById('main'));

            var option = {
                title:{
                    text: "未来一周气温变化",
                    subtext: '纯属虚构'
                },
                tooltip : {
                    trigger: 'axis'
                },
                legend: {
                    data:['最高气温','最低气温']
                },
                toolbox: {
                    show : true,
                    feature : {
                        mark : {show: true},
                        dataView : {show: true, readOnly: false},
                        magicType : {show: true, type: ['line', 'bar']},
                        restore : {show: true},
                        saveAsImage : {show: true}
                    }
                },
                calculable : true,
                xAxis : [
                    {
                        type : 'category',
                        boundaryGap : false,
                        data : ['周一','周二','周三','周四','周五','周六','周日']
                    }
                ],
                yAxis : [
                    {
                        type : 'value',
                        axisLabel : {
                            formatter: '{value} °C'
                        }
                    }
                ],
                series : [
                    {
                        name:'已下单票类',
                        type:'line',
                        data:[<?php echo $ti1;?>],
                        markPoint : {
                            data : [
                                {type : 'max', name: '最大值'},
                                {type : 'min', name: '最小值'}
                            ]
                        },
                        markLine : {
                            data : [
                                {type : 'average', name: '平均值'}
                            ]
                        }
                    },
                    {
                        name:'已完成的票类',
                        type:'line',
                        data: [<?php echo $ti2;?>],
                        markPoint : {
                            data : [
                                {name : '周最低', value : -2, xAxis: 1, yAxis: -1.5}
                            ]
                        },
                        markLine : {
                            data : [
                                {type : 'average', name : '平均值'}
                            ]
                        }
                    }
                    {
                        "name":"预计销量",
                        "type":"line",
                        "data":[<?php echo $ti3;?>]
                    }
                ]
            };
            // 为echarts对象加载数据
            myChart.setOption(option);
        }
    );



    $("#txtStartTime").bind("click focus", function () {

        var endtimeTf = $dp.$('txtEndTime');
        WdatePicker({
            maxDate: '#F{$dp.$D(\'txtEndTime\')}',
            dateFmt: "yyyy-MM-dd",
            onpicked: function () { endtimeTf.focus(); }
        });
    });
    $("#txtEndTime").bind("click focus", function () {
        WdatePicker({
            minDate: '#F{$dp.$D(\'txtStartTime\')}',
            dateFmt: "yyyy-MM-dd"
        });
    });

</script>
</body>
</html>